<template>
<div  class="page">
    <div class="header">
        <el-input
            class="search"
            placeholder="请输入yapi的网页url"
            prefix-icon="el-icon-search"
            v-model="searchKey">
        </el-input>
        <el-button type="primary" @click="startWithRootUrl">根页面搜索</el-button>
        <el-button type="primary" @click="startWithSingleUrl">单页面搜索</el-button>
    </div>
</div>
</template>

<script>
import axios from 'axios'
export default {
    name: "yapi-source",
    data(){
        return {
            searchKey:'http://172.17.20.29:3000/group/123'
        }
    },
    mounted(){
        
    },
    methods: {

        /***
         * 登录yapi
         */
        loginForYapi(){
            let dataForm = {
                "email": "2014375614@qq.com", 
                "password": "a1255197195"
            }
            axios.post( 'http://172.17.20.29:3000/api/user/login', dataForm ).then( res=>{
                console.log("loginByYapi");
                console.log(res);

                let allCookies = document.cookie
                console.log("allCookies: ")
                console.log(allCookies)
            } )
        },


        /***
         * 开始根据yapi的根页面url查找
         */
        startWithRootUrl(){
            this.loginForYapi(); 
            axios.get(this.searchKey).then( res=>{
                console.log(res)
            } );
        },

        /***
         * 开始根据yapi的单个页面url查找
         */
        startWithSingleUrl(){

        }
    }
}
</script >

<style scoped lang="less">

.header {
    margin: 50px 50px;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    .search {
        width: 500px;
        margin-right: 20px;
    }
}


</style>